<template>
  <div class="account-login">
    <div class="form-group">
      <label for="username">用户名</label>
      <input type="text" id="username" v-model="username" placeholder="请输入用户名" />
    </div>
    <div class="form-group">
      <label for="password">密码</label>
      <input type="password" id="password" v-model="password" placeholder="请输入密码" />
    </div>
    <div class="remember-forgot">
      <label> <input type="checkbox" v-model="remember" /> 记住我 </label>
      <a href="#">忘记密码？</a>
    </div>
    <button @click="handleLogin" class="login-btn">登录</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const username = ref('')
const password = ref('')
const remember = ref(false)

// 发送登录表单事件
const emit = defineEmits(['login'])

const handleLogin = () => {
  if (!username.value || !password.value) {
    alert('请输入用户名和密码')
    return
  }

  // 向父组件发送登录信息
  emit('login', {
    type: 'account',
    username: username.value,
    password: password.value,
    remember: remember.value,
  })
}
</script>

<style scoped>
.account-login {
  width: 100%;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #666;
  font-size: 14px;
}

input[type='text'],
input[type='password'] {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  transition:
    border 0.3s,
    box-shadow 0.3s;
  background-color: rgba(255, 255, 255, 0.8);
}

input[type='text']:focus,
input[type='password']:focus {
  border-color: #ff69b4;
  outline: none;
  box-shadow: 0 0 8px rgba(255, 105, 180, 0.3);
}

.remember-forgot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 14px;
}

.remember-forgot a {
  color: #ff69b4;
  text-decoration: none;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(45deg, #ff69b4, #ff8da1);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
}

.login-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(255, 105, 180, 0.4);
}
</style>
